package com.yanqu.road.server.cmd.sync;


import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.syncMessage.SyncMessage;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.server.protocol.GameProtocol;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.C_SERVICE_BACK_MESSAGE, desc = "转发游戏返回游戏服的消息")
public class BackMessageCmd extends CrossCommand {

    private SyncMessage.Response response;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        this.response = SyncMessage.Response.parseFrom(packet.getBytes());
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        if (this.response.hasForwardServerId()) {
            if (this.response.getForwardServerId() > 0) {
                packet.setCode(GameProtocol.S_CROSS_SERVICE_MESSAGE_RESP);
                MessageHelper.sendPacket(this.response.getForwardServerId(), packet.getPlayerId(), packet);
            }
        }
    }

    @Override
    public void sendData() {

    }
}
